/**
 实现一个化妆品商城中的化妆品管理
 1.定义一个化妆品类(Cosmetic)name，type，price
 2.定义一个化妆品管理类(cosmeticManager)
 	1.实现进货功能
 	2.可以输出所有化妆品信息功能
 3.使用继承实现一个可按单价排序输出所有化妆品的功能
 4.使用继承实现一个只输出进口化妆品的功能
 */

/*
package com.leo.第五章_面向对象下;

public class U5_L6_继承小案例_化妆品分类 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Cosmetic cosmetic=new Cosmetic("YSL","进口",99);
		//cosmetic.getinfo();
		
		// 因为还没有学习多态 所以就三个类型轮着用 后面有选项，注意包装的打印问题。 有些在方法内就打印了不需要在打印一次
		//1.CosmeticManger cm=new CosmeticManger();
		//2.Cosmetic_sort cm =new Cosmetic_sort();
		//3.ImportCosmeticManger cm=new ImportCosmeticManger();
		cm.add(new Cosmetic("a2","进口",123));
		cm.add(new Cosmetic("b3","进口",53));
		cm.add(new Cosmetic("c4","进口",82));
		cm.add(new Cosmetic("d5","国产",13));
		cm.add(new Cosmetic("e6","国产",26));
		cm.add(new Cosmetic("f7","进口",36));
		//cm.getinfo_Mg();  //1.CosmeticManger
		//cm.sort();		//2.Cosmetic_sort
		//cm.printinfo();	//3.ImportCosmeticManger		
	}
}


class CosmeticManger{
	protected CosmeticManger() {} 
	protected Cosmetic[] cs=new Cosmetic[5];
	static int count=0;
	public void add(Cosmetic vo) {
		int size=cs.length;			
		if(count>=size) {
			int newlen=size*3/2+1;
			cs=java.util.Arrays.copyOf(cs, newlen);	
		}
		cs[count++]=vo;
	}
	
	private String warp_getinfo_Mg() {
		System.out.print("[");	
		for(int i=0;i<count;i++) {
			System.out.print(" "+(i+1)+".("+cs[i].getName()+" "+cs[i].getType()+" "+cs[i].getPrice()+" )");
		//	" 产品名字: "+name+" 产品类型: "+type+" 产品价格: "+price+" ");
		}
		System.out.println(" ]");
		return "***************warp_getinfo_Mg****************";
	}

	public String getinfo_Mg() {
		String getinfo_Mg=warp_getinfo_Mg();
		return getinfo_Mg;
	}
}

class Cosmetic_sort extends CosmeticManger{
	
	public void sort() {
		Cosmetic[]temp =java.util.Arrays.copyOf(cs, count);
		Cosmetic c=null;
		int len=temp.length;	
		for(int i=0;i<len-1;i++) {
			for(int j=0;j<len-i-1;j++) {
				if(temp[j].getPrice()>temp[j+1].getPrice()) {
					c=temp[j];
					temp[j]=temp[j+1];
					temp[j+1]=c;
				}
			}
		}
		for(Cosmetic vo:temp) {
			vo.getinfo();
		}
	}
}

class ImportCosmeticManger extends CosmeticManger{
	public void printinfo() {
		for(int i=0;i<count;i++) {
			if("进口".equals(cs[i].getType())) {
				cs[i].getinfo();
			}
		}
	}
}

class Cosmetic{
	private String name;
	private String type;
	private int price;
	public Cosmetic() {};
	
public Cosmetic(String name,String type,int price) {
		this.name=name;
		this.type=type;
		this.price=price;
	}

	public String getName() {
		return name;
	}

	public void set_Name(String name) {
		this.name=name;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public int getPrice() {
		return price;
	}

	public void setPrice(int price) {
		this.price = price;
	}

	public String getinfo() {
		System.out.println(" 产品名字: "+name+" 产品类型: "+type+" 产品价格: "+price+" ");
		return " 产品名字: "+name+" 产品类型: "+type+" 产品价格: "+price+" ";
	}
}
*/


